package com.happy_hao.topbiz.controller.base.msgController;


import com.happy_hao.topbiz.api.MsgApi;
import com.happy_hao.topbiz.common.Result;
import com.happy_hao.topbiz.dto.msgDto.TemplateRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/topbiz/msg/template")
public class TemplateController {

    @Autowired
    private MsgApi msgApi;

    @PutMapping("/addTemplate")
    public Result addTemplate(@Valid @RequestBody TemplateRequest templateRequest){
        return msgApi.addTemplate(templateRequest);
    }

    @GetMapping("/getAllTemplate")
    public Result getAllTemplate(){
        return msgApi.getAllTemplate();
    }

    @DeleteMapping("/deleteTemplate")
    public Result deleteTemplate(@RequestParam("title") String title){
        return msgApi.deleteTemplate(title);
    }

    @PostMapping("/updateTemplate")
    public Result updateTemplate(@Valid @RequestBody TemplateRequest templateRequest){
        return msgApi.updateTemplate(templateRequest);
    }

}
